package com.woniuxy.woniuhis.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.woniuxy.woniuhis.entity.SurgeryRole;
import com.woniuxy.woniuhis.service.SurgeryRoleService;
import com.woniuxy.woniuhis.util.ResponseJson;

@Controller
@RequestMapping("surgeryrole")
public class SurgeryRoleController {
	
	@Autowired
	SurgeryRoleService surgeryRoleServie;
	
	@RequestMapping("/all")
	@ResponseBody
	public ResponseJson getAllSurgeryRoles(@RequestBody SurgeryRole surgeryRole) {
		ResponseJson responseJson = new ResponseJson();
		
		try {
			if(surgeryRole == null) {
				surgeryRole = new SurgeryRole();
			}
			List<SurgeryRole> roles = surgeryRoleServie.findSurgeryRoles(surgeryRole);
			responseJson.setData(roles);
			responseJson.setCount(roles.size());
			responseJson.setCode(0);
			return responseJson;
		} catch (Exception e) {
			responseJson.setCode(1);
			responseJson.setMsg(e.toString());
			e.printStackTrace();
			return responseJson;
		}
	}

}
